package org.hot100.h283;

import java.util.*;

/**
 * @Author: wjy
 * @Date: 2022/3/3 14:50
 */
public class Solution {

    public static void main(String[] args) {
        int[] ints = {0, 1, 0, 3, 12};

        Solution solution = new Solution();
        solution.moveZeroes(ints);
        System.out.println(Arrays.toString(ints));
    }

    public void moveZeroes(int[] nums) {

        List<Integer> list = new LinkedList<>();

        for (int i: nums) {
            if (i != 0) {
                list.add(i);
            }
        }

        for (int i = 0; i < list.size(); i++) {
            nums[i] = list.get(i);
        }

        for (int i = 0; i < nums.length - list.size(); i++) {
            nums[list.size() + i] = 0;
        }

        System.out.println(Arrays.toString(nums));

    }

}
